package com.lxp.test;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallbackExtended;
import org.eclipse.paho.client.mqttv3.MqttMessage;
@Slf4j
public class OnMessageCallback implements MqttCallbackExtended {

    @Override
    public void connectionLost(Throwable throwable) {
        System.out.println("连接断开，可以坐重连！");
    }

    @Override
    public void messageArrived(String topic, MqttMessage message) {
        System.out.println("接收消息主题：" + topic);
        System.out.println("接收消息Qos:" + message.getQos());
        System.out.println("接收消息内容：" + new String(message.getPayload()));
    }

    @Override
    public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
        System.out.println("deliveryComplete---------" + iMqttDeliveryToken.isComplete());
    }

    @Override
    public void connectComplete(boolean b, String s) {
        log.info("=======连接MQTT HOST 成功");
    }
}
